home *** CD-ROM | disk | FTP | other *** search
/ Java 1996 August / Java - Summer 1996.iso / kaffe-0.2 / config / i386-solaris2-md.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-13  |  3.6 KB  |  156 lines

  1. /*
  2.  * i386-solaris2-md.h
  3.  * Solaris2 i386 specific information (registers, exceptions, etc.)
  4.  *
  5.  * Copyright (c) 1996 Systems Architecture Research Centre,
  6.  *           City University, London, UK.
  7.  *
  8.  * See the file "license.terms" for information on usage and redistribution
  9.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  10.  *
  11.  * Written by Tim Wilkinson <tim@sarc.city.ac.uk>, February 1996.
  12.  */
  13.  
  14. #ifndef __i386_solaris2_md_h
  15. #define __i386_solaris2_md_h
  16.  
  17. /* Nr. of registers used to map stack */
  18. #define    NRREG        4
  19.  
  20. #define    REG_eax        0
  21. #define    REG_ecx        1
  22. #define    REG_edx        2
  23. #define    REG_ebx        3
  24. #define    REG_esp        4
  25. #define    REG_ebp        5
  26. #define    REG_esi        6
  27. #define    REG_edi        7
  28.  
  29. #define    REG_BASE    REG_ebp
  30. #define    REG_STACK    REG_esp
  31.  
  32. #define    INSTRUCTION_PUSH(r)                        \
  33.     asm__pushl_R(r->regno)
  34.  
  35. #define    INSTRUCTION_POP(r)                        \
  36.     asm__popl_R(r->regno)
  37.  
  38. #define    INSTRUCTION_PROLOGUE(sz)                    \
  39.     asm__pushl_R(REG_ebp);                        \
  40.     asm__movl_RxR(REG_esp, REG_ebp);                \
  41.     asm__subl_VxR((sz)*4, REG_esp);
  42.  
  43. #define    INSTRUCTION_MONITORENTER(m)                    \
  44.     if (m->accflags & ACC_STATIC) {                    \
  45.         asm__pushl_V(m->class);                    \
  46.     }                                \
  47.     else {                                \
  48.         asm__movl_VoRoxR(4 * ((m->ins+1)+1), REG_BASE, REG_eax);\
  49.         asm__pushl_R(REG_eax);                    \
  50.     }                                \
  51.     asm__call_X(soft_monitorenter);                    \
  52.     asm__addl_VxR(4, REG_STACK)
  53.  
  54. #define    LOCAL_FIXUP(offset, nargs)                    \
  55.     ((offset) >= (nargs) ? (nargs) - (offset) - 1: (nargs) - (offset) + 1)
  56.  
  57. #if 0
  58. #define    CALL_KAFFE_FUNCTION(f)                        \
  59.     asm("    pushal                            \n\
  60.         call *%0                        \n\
  61.         popal" : : "r" (f))
  62. #endif
  63.  
  64. #define    CALL_KAFFE_FUNCTION_VARARGS(f, o, a, ap)            \
  65.     asm("    pushal                            \n\
  66.         movl %%esp,%%ebp                    \n\
  67.         pushl %1                        \n\
  68. 1:        cmpl $0,%2                        \n\
  69.         je 2f                            \n\
  70.         pushl (%3)                        \n\
  71.         addl $4,%3                        \n\
  72.         subl $1,%2                        \n\
  73.         jmpl 1b                            \n\
  74. 2:                                    \n\
  75.         call *%0                        \n\
  76.         movl %%ebp,%%esp                    \n\
  77.         popal" : : "r" (f), "r" (o), "r" (a), "r" (ap))
  78.  
  79. #define    CALL_KAFFE_EXCEPTION(frame, info, obj)                \
  80.     asm("    pushl %2                        \n\
  81.         movl %0,%%ebp                        \n\
  82.         jmp *%1                            \n\
  83.         " : : "g" (frame->retbp), "r" (info.handler), "g" (obj))
  84.  
  85. /**/
  86. /* Exception handling information */
  87. /**/
  88.  
  89. typedef struct _exceptionFrame {
  90.     int            retbp;
  91.     int            retpc;
  92. } exceptionFrame;
  93.  
  94. #define    FIRSTFRAME(f)    (exceptionFrame*)(((int)&f) - 12)
  95. #define    NEXTFRAME(f)    (exceptionFrame*)((f)->retbp)
  96.  
  97. /**/
  98. /* Thread handling */
  99. /**/
  100.  
  101. #define    THREADSTACKSIZE        (32 * 1024)
  102.  
  103. #define    THREADSWITCH(to, from)                    \
  104.     asm("    pushl $1f                    \n\
  105.         pushal                        \n\
  106.         movl %%esp,%0                    \n\
  107.         movl %1,%%esp                    \n\
  108.         popal                        \n\
  109.         ret                        \n\
  110. 1:        nop                        \n\
  111.         " : : "g" (from->restorePoint), "g" (to->restorePoint))
  112.  
  113. #define    THREADINIT(to, func)                    \
  114.     asm("                            \n\
  115.         movl %0,-4(%1)                    \n\
  116.         movl $0,-8(%1)  # eax                 \n\
  117.         movl $0,-12(%1) # ecx                 \n\
  118.         movl $0,-16(%1) # edx                 \n\
  119.         movl $0,-20(%1) # ebx                 \n\
  120.         movl $0,-24(%1) # ---                 \n\
  121.         movl $0,-28(%1) # ebp                 \n\
  122.         movl $0,-32(%1) # esi                 \n\
  123.         movl $0,-36(%1) # edi                 \n\
  124.         " : : "r" (func), "r" (to->stackEnd));        \
  125.         to->restorePoint = to->stackEnd - 36
  126.  
  127. #define    THREADINFO(ee)                        \
  128.         do {                        \
  129.             void** ptr;                \
  130.             asm("movl %%ebp,%0" : "=r" (ptr));    \
  131.             while (*ptr != 0) {            \
  132.                 ptr = (void**)*ptr;        \
  133.             }                    \
  134.             (ee)->restorePoint = 0;            \
  135.             (ee)->stackBase = (void*)ptr;        \
  136.             (ee)->stackEnd = 0;            \
  137.         } while(0)
  138.  
  139. #define    THREADFRAMES(tid, cnt)                    \
  140.         do {                        \
  141.             void** ptr;                \
  142.             cnt = 0;                \
  143.             if (tid == currentThread) {        \
  144.                 asm("movl %%ebp,%0" : "=r" (ptr));\
  145.             }                    \
  146.             else {                    \
  147.                 ptr = ((void***)tid->eetop->restorePoint)[2];\
  148.             }                    \
  149.             while (*ptr != 0) {            \
  150.                 cnt++;                \
  151.                 ptr = (void**)*ptr;        \
  152.             }                    \
  153.         } while (0)
  154.  
  155. #endif
  156.